<template>
  <div
    @click="visible = false"
    :class="{
      ' Cultural-box-loop': !route.meta.loopType,
    }"
    class="jy-style-height research-box"
    :style="{
      'background-image': `url(${publicUrls + 'free/style15/copyrightBg1.png' + '?imageView2/3/format/webp'})`,
    }"
  >
    <div class="research-heard">
      <div class="heard-blank" @click="blankHome">
        <i class="freeIcon">&#xe642;</i>
      </div>
      <!-- <span class="titles">学术研究</span> -->
      <div class="heard-title">
        <span>学术研究</span>
      </div>
      <!-- v-if="!store.isMobileType" -->
      <div
        class="heard-right"
        @click.stop="visible = !visible"
        :style="list.length === 0 && parmas.typeId === 0 ? { opacity: '0', cursor: 'default' } : { opacity: '1' }"
      >
        <span>{{ TypeTitle }}</span>
        <i class="doorIcon" v-if="!visible">&#xe63a;</i>
        <i class="doorIcon" v-else>&#xe63e;</i>
        <div
          class="menu-box"
          :class="{ 'menu-box-active': visible }"
          :style="{ 'min-width': store.isMobileType ? '110px' : '80px' }"
        >
          <div
            :class="{ 'item-active': parmas.typeId === 0 }"
            class="pop-item pop-item-0 hw-click-cursor"
            @click.stop="setTypeId(0)"
          >
            <span
              >全部

              <div class="solider"></div>
            </span>
          </div>
          <div
            :class="{ 'item-active': parmas.typeId === item.id }"
            class="pop-item hw-click-cursor"
            @click.stop="setTypeId(item)"
            v-for="item in props.selectList"
            :key="item.id"
          >
            <span>
              {{ item.text }}
              <div class="solider"></div>
            </span>
          </div>
        </div>
      </div>
    </div>

    <div
      class="researches-content"
      :style="{
        'background-image': `url(${publicUrls + 'free/style15/copyrightBg2.png' + '?imageView2/3/format/webp'})`,
      }"
    >
      <div class="researches-content-item">
        <scrollBox
          color="rgba(50, 43, 37, 1)"
          :scrollSrc="publicUrls + 'free/style15/pen.png'"
          v-if="scrollheight && !loading"
          :byid="98627"
          :height="getScrollHeight"
          :tabbmScroll="getTabmComputed"
        >
          <template #solidBorderCon>
            <div class="researches-list" ref="scrollContainers" @scroll="handleScroll">
              <div class="is-null" v-if="list.length === 0 && !loading"><span>暂无学术研究</span></div>
              <div
                class="item"
                style="marginbottom: 30px"
                v-else
                v-for="item in list"
                :key="item.id"
                @click="pathInfo(item.id)"
              >
                <div class="item-left">
                  <div class="title1">
                    <div v-if="item.typeId" class="title1-color">
                      【{{
                        item.typeId == 401792425939013
                          ? '课题研究'
                          : item.typeId == 401792277585989
                          ? '出版刊物'
                          : '论文论著'
                      }}】
                    </div>
                    <div class="title1-names">{{ item.name }}</div>
                  </div>
                  <span class="title2">{{ item.publishedOn }}</span>
                </div>
                <div class="item-right">
                  <p class="title3">{{ item.author }}</p>
                  <span class="title4">{{ item.publisher }}</span>
                </div>
              </div>
            </div>
          </template>
          <template #solidBorderEx>
            <div class="solidBorder-child"></div>
          </template>
        </scrollBox>
      </div>
    </div>
    <!-- <a
      :href="doorUrl"
      target="blank"
      class="logo-box"
      :style="{
        'background-image': `url(${publicUrls + 'free/style5/template5Logobg.png' + '?imageView2/3/format/webp'})`,
      }"
    ></a> -->
  </div>
  <MenuNavigation />
</template>

<script lang="ts">
export default defineComponent({
  name: 'style1',
});
</script> 

<script setup lang="ts">
import MenuNavigation from '@/freeComponents/menuNavigation/index.vue';
import { publicUrls, doorUrl } from '@/utils/minxin';
import { treeList } from '@/api/user/user';
import RightMenu from '../components/rightMenu.vue';
import Logo from '../components/logo.vue';
import FooterHome from '../components/footerHome.vue';
import PublicTitle from '../components/PublicTitle.vue';
import { useRouter, useRoute } from 'vue-router';
import { ref, watch, reactive, onActivated, nextTick, computed, defineComponent } from 'vue';
import { copyrightSave, copyrightInfo } from '@/api/templates/templates';
import { useProjectStore, commonDataStore } from '@/store';
import { storeToRefs } from 'pinia';
import scrollBox from '@/freeComponents/exhibitsDialog/style10/component/scrollBox10.vue';
import { investigationList } from '@/api/investigation/investigation';

const props = defineProps({
  selectList: {
    type: Object,
  },
});
const scrollNumber = ref(0);
const heartbeat = ref(0); //页面心跳值
const store = useProjectStore();
const router = useRouter();
const scrollheight = ref();
const route = useRoute();
const current = ref(1);
const pageSize = ref(20);
const types = ref(true);
const visible = ref(false);
const parmas = reactive({
  value: '',
  pageNo: 1,
  pageSize: 20,
  typeId: 0,
});
const TypeTitle = ref('全部');
const list = ref([]);
const total = ref(0);
const loading = ref(false);
const scrollContainers = ref(null);

let viewportheight = window.innerHeight;
scrollheight.value = (viewportheight / 900) * 558;

const getScrollHeight = computed(() => {
  let rootNode = document.documentElement;

  // 获取计算后的样式
  let computedStyle = window.getComputedStyle(rootNode);

  // 读取字体大小（注意这里返回的可能是一个包含单位的字符串，如"16px"）
  let fontSize = computedStyle.fontSize;

  // 如果你需要一个数字值（不带单位）进行计算，你可能需要解析这个字符串
  // 例如，使用正则表达式或split()方法去除单位，并将结果转换为数字
  let fontSizeNumber = parseFloat(fontSize.replace(/[^0-9.-]/g, ''));
  let heights = (fontSizeNumber / 144) * 560;
  return heights;
});
const getTabmComputed = computed(() => {
  let rootNode = document.documentElement;

  // 获取计算后的样式
  let computedStyle = window.getComputedStyle(rootNode);

  // 读取字体大小（注意这里返回的可能是一个包含单位的字符串，如"16px"）
  let fontSize = computedStyle.fontSize;

  // 如果你需要一个数字值（不带单位）进行计算，你可能需要解析这个字符串
  // 例如，使用正则表达式或split()方法去除单位，并将结果转换为数字
  let fontSizeNumber = parseFloat(fontSize.replace(/[^0-9.-]/g, ''));
  let heights = (fontSizeNumber / 144) * 24;
  return heights;
});
const init = async (e?: number) => {
  try {
    if (loading.value) {
      return;
    }
    loading.value = true;
    let res = await investigationList(localStorage.getItem('projectId'), parmas);
    total.value = res.data.total;
    if (e) {
      list.value = [];
    }
    list.value = list.value.concat(res.data.data);
    loading.value = false;
    console.log(list.value);
  } catch {
    loading.value = false;
  }
};
const pageWheel = (event: any) => {
  //滚动
  const delta = Math.sign(event.wheelDelta || -event.detail);
  console.log(delta);
  if (delta > 0) {
    scrollContainers.value.scrollTop = scrollContainers.value.scrollTop - 50;
  } else {
    scrollContainers.value.scrollTop = scrollContainers.value.scrollTop + 50;
  }
  event.preventDefault();
  // rightScroll
};
const setTypeId = (e: any) => {
  if (e === 0) {
    parmas.typeId = 0;
    TypeTitle.value = '全部';
  } else {
    parmas.typeId = e.id;
    TypeTitle.value = e.text;
  }
  visible.value = false;
  parmas.pageNo = 1;
  init(2);
};
const handleScroll = () => {
  //滚动加载逻辑

  const scrollContainer = scrollContainers.value;
  const distanceToBottom = scrollContainer.scrollHeight - (scrollContainer.scrollTop + scrollContainer.clientHeight);
  scrollNumber.value = scrollContainer.scrollTop;
  if (distanceToBottom <= 50 && !loading.value && list.value.length < total.value) {
    parmas.pageNo = parmas.pageNo + 1;
    init();
  }
};
const pathInfo = (e: number) => {
  //查看详情
  router.push({
    name: route.meta.loopType ? 'templateresearchLoop' : 'templateresearch',
    query: {
      id: e,
    },
  });
};
init();
onActivated(() => {
  // heartbeat.value
  loading.value = true;
  nextTick(() => {
    loading.value = false;
  });
  if (heartbeat.value !== store.heartbeatCurrent) {
    scrollContainers.value.scrollTop = 0;
    scrollNumber.value = 0;
    parmas.typeId = 0;
    TypeTitle.value = '全部';
    parmas.pageNo = 1;
    init(2);
  } else {
    nextTick(() => {
      scrollContainers.value.scrollTop = scrollNumber.value;
    });
  }
  heartbeat.value = store.heartbeatCurrent;
});
const blankHome = () => {
  router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
};
</script>

<style scoped lang="less">
.research-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 40px 60px;
  padding-bottom: 0px;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}
.Cultural-box-loop {
  padding-top: 20px;
}
.logo-box {
  width: 287px;
  height: 26px;
  position: absolute;
  bottom: 20px;
  left: calc(50% - 143.5px);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.research-heard {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 1320px;
  height: 66px;
  margin-bottom: 14px;

  .heard-title {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    height: 56px;
    span {
      font-family: SourceHanSerifCN-Bold;
      font-size: 36px;
      line-height: 56px;
      text-align: center;
      color: rgba(2, 76, 63, 1);
    }
  }
  .heard-blank {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: #c3b7a3;
    box-shadow: 0.5px 0.5px 3px 0px rgba(0, 0, 0, 0.15) inset;
    .freeIcon {
      cursor: pointer;

      font-size: 36px;
      line-height: 36px;
      color: rgba(250, 238, 220, 1);
    }
  }
}
.heard-right {
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 120px;
  span {
    font-family: PingFang SC;
    font-size: 18px;
    line-height: 24px;

    color: rgba(2, 76, 63, 1);
  }
  .doorIcon {
    font-size: 18px;
    line-height: 24px;
    color: rgba(2, 76, 63, 1);
    margin-left: 8px;
  }
}
.menu-box {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 36px;
  left: 50%;
  height: 0px;
  transform: translateX(-50%);
  width: 96px;
  min-width: 96px;
  padding: 0px 0px;
  background: #fff;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.1);
  // border-radius: 8px;
  overflow: hidden;
  transition: height 0.3s;
  z-index: 123;
}
.menu-box-active {
  height: auto;
  padding: 8px 0px;
}
.pop-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  margin-top: 8px;
  font-family: PingFang SC;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: rgba(2, 76, 63, 0.6);
  flex-shrink: 0;
  padding: 0px;
  span {
    position: relative;
    color: rgba(2, 76, 63, 0.6);
  }
}
.pop-item-0 {
  margin-top: 0px;
}
.pop-item:hover {
  background: none;
  color: rgba(2, 76, 63, 1);
  span {
    color: rgba(2, 76, 63, 1);
  }
  // text-decoration: underline;
  .solider {
    opacity: 1;
  }
}
.item-active {
  position: relative;
  color: rgba(2, 76, 63, 1);
  span {
    color: rgba(2, 76, 63, 1);
  }
  .solider {
    opacity: 1;
  }
  // text-decoration: underline;
}
.solider {
  opacity: 0;
  position: absolute;
  left: 0;
  bottom: 1px;
  width: 100%;
  height: 1px;
  background: rgba(2, 76, 63, 1);
}

.researches-content {
  display: flex;
  width: 1320px;
  height: 740px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 90px 110px; 
  box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.1);
}
.researches-content-item {
  width: calc(1320px - 220px);
}
.researches-list {
  width: 100%;
  // padding-left: 100px;
}
.researches-list::-webkit-scrollbar {
  display: none;
}
.is-null {
  margin: 0 auto;
  margin-left: 35px;
  margin-top: 200px;
  text-align: center;
  span {
    font-size: 20px;
    line-height: 32px;
    color: #92afa8;
  }
}
.item {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 99px;
  padding: 19.5px 0;
  border-bottom: 1px solid rgba(236, 229, 216, 1);
}
.item:hover {
  // background: rgba(98, 51, 51, 0.04);
  // box-shadow: inset 0px -1px 0px 0px #623333;
}
.item-left {
  display: flex;
  flex-direction: column;
  width: 840px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title1 {
  display: flex;
  align-items: center;
  width: 100%;
  .title1-color {
    display: flex;
    align-items: center;
    justify-content: left;
    width: 106px;
    height: 32px;
    font-family: SourceHanSerifCN-Bold;
    font-weight: 400;
    font-size: 17px;
    color: rgba(2, 76, 63, 1);
    line-height: 32px;
    margin-bottom: 0;
  }
  .title1-names {
    text-align: left;
    max-width: calc(100% - 320px);
    font-family: SourceHanSerifCN-Bold;
    font-size: 17px;
    color: rgba(51, 51, 51, 1);
    line-height: 32px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.title2 {
  font-weight: 400;
  font-size: 14px;
  color: rgba(51, 51, 51, 1);
  line-height: 26px;

  opacity: 0.5;
}
.item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title3 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: SourceMedium;
  font-size: 17px;
  color: rgba(51, 51, 51, 1);
  line-height: 32px;
  text-align: right;
}
.title4 {
  max-width: 100%;
  overflow: hidden;
  font-family: 'SourceHanSerifCN';
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: PingFang SC Microsoft YaHei;
  font-size: 14px;
  color: rgba(51, 51, 51, 0.5);
  line-height: 26px;
  text-align: right;
}

.solidBorder-child {
  width: 2px;
  height: 100%;
  background: #c3b7a3;
  border-radius: 1px;
  opacity: 0.6;
}
:deep(.templatestyle1-scroll-box-tumb) {
  display: flex;
  justify-content: center;
  img {
    width: 24px;
    height: 24px;
  }
}
.researches-list {
}
:deep(.unit-exbit-null-remarks-info) {
  width: 100%;
}
:deep(.unit-exbi-remarks-info-remarks) {
  width: calc(100% - 5px) !important;
}
:deep(.solid-box-parent) {
  position: absolute;
  right: -60px;
}
.footer-logo-box {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 276px;
  height: 24px;
}
:deep(.unit-exbi-remarks-info-remarks) {
  width: 100% !important;
}
:deep(.solid-box-parent-p) {
  // right: -0.27778rem;
}
:deep(.templatestyle1-scroll-box-tumb) {
  height: 24px;
}
:deep(.tumb-max) {
  top: calc(100% - 24px) !important;
}
::v-deep .templatestyle1-scroll-box-tumb {
  align-items: center;
  justify-content: center;
  img {
    margin-top: -4px;
    transform: scale(1.3);
  }
}
</style>